#pragma once
/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * Safe GDI Handle Class
 *      Provides a safe handle implementation for wrapping a GDI handle.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
#include "stdafx.h"
using namespace System;
using namespace System::Runtime;
using namespace System::Runtime::InteropServices;

namespace Adaptive
{
	namespace Win32
	{
		namespace Gdi
		{
			/// <summary>
			/// Provides a safe handle implementation for wrapping a GDI handle.
			/// </summary>
			public ref class SafeGdiHandle : public SafeHandle 
			{
			public:
				/*--------------------------------------------------------------------------------
				 * Constructor / Dispose / Destructor Methods
				 *------------------------------------------------------------------------------*/
				#pragma region Constructor / Dispose / Destructor Methods
				/// <summary>
				/// Initializes a new instance of the class.
				/// </summary>
				/// <remarks>
				/// This is the default constructor.
				/// </remarks>
				SafeGdiHandle();
				/// <summary>
				/// Initializes a new instance of the class to the specified handle value.
				/// </summary>
				/// <param name="originalHandle">The original handle value.</param>
				SafeGdiHandle(IntPtr^ originalHandle);
				/// <summary>
				/// Initializes a new instance of the class to the specified handle value.
				/// </summary>
				/// <param name="originalHandle">The original handle value.</param>
				SafeGdiHandle(IntPtr originalHandle);
				#pragma endregion

				/*--------------------------------------------------------------------------------
				 * Public Properties
				 *------------------------------------------------------------------------------*/
				#pragma region Public Properties
				/// <summary>
				/// Gets the underlying handle value.
				/// </summary>
				/// <value>
				/// An <see cref="IntPtr"/> value indicating the underlying handle.
				/// </value>
				property IntPtr HandleValue { IntPtr get(); }
				/// <summary>
				/// Gets a value indicating whether the underlying handle is invalid.
				/// </summary>
				/// <value>
				/// <b>true</b> if the underlying handle value is an invalid handle or null value;
				/// otherwise, <b>false</b>.
				/// </value>
				property bool IsInvalid { bool virtual get() override; }
				#pragma endregion
	 
			protected:
				/*--------------------------------------------------------------------------------
				 * Constructor / Dispose / Destructor Methods
				 *------------------------------------------------------------------------------*/
				#pragma region Constructor / Dispose / Destructor Methods
				/// <summary>
				/// Initializes a new instance of the class to the specified unmanaged handle value.
				/// </summary>
				/// <param name="originalHandle">The original handle value.</param>
				SafeGdiHandle(HGDIOBJ originalHandle);

				/*--------------------------------------------------------------------------------
				 * Protected Methods / Event Methods
				 *------------------------------------------------------------------------------*/
				#pragma region Protected Methods / Event Methods
				/// <summary>
				/// Releases the underlying handle value.
				/// </summary>
				virtual bool ReleaseHandle() override;
				#pragma endregion
			};
		}
	}
}